const userAgent = require('user-agent');

class SendTracker {
  constructor() {
    this.url = 'http://49.234.56.177:8888/dig.gif'; // 上报路径
  }
  send(log = {}) {
    log = JSON.stringify({ ...log, ...this.getExtraData() });
    const img = new window.Image();
    debugger;
    img.src = `${this.url}?d=${encodeURIComponent(log)}`;
  }
  getExtraData() {
    return {
      title: document.title,
      url: location.href,
      timestamp: Date.now(),
      userAgent: userAgent.parse(navigator.userAgent),
    };
  }
}
export default new SendTracker();
